package com.whpu.admin.interceptor;

import com.whpu.pojo.User;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by RiceBall on 2020/10/23 10:17
 */
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        User user = (User) request.getSession().getAttribute("USER");
        if (user != null) {
            return true;
        } else {
            response.sendRedirect("/login.jsp");
        }
        return false;
    }
}
